Improve Delivery caching reliability and invalidation - #18
Merged
Conversation
…te from the consumer's entry options
…e cached fetch, drop what nothing reaches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve Delivery caching reliability and invalidation
This PR fixes several issues found during a review of the Delivery caching layer and simplifies some of the related internals.
What changed
Fail-safe behavior
Fail-safe now distinguishes between an unavailable origin and a valid response indicating that no value exists.
404return normally and remove the stale cached value.IDeliveryCacheManagerkeeps the same API; the behavior ofnullvs. an exception is now documented.Cache invalidation
TagsDefaultEntryOptions, which defaults to 10 days and can be configured by consumers.DeliveryCacheDependencies.ForItem,ForType,ForTaxonomy, andForAssetfor composing dependency keys.Cache isolation and Redis
CacheKeyPrefix.{KeyPrefix}:{EnvironmentId}:v1:{key}.1, so size-limited memory caches work correctly.Existing Redis entries using the previous key format will remain unused until they expire.
Configuration and cache manager access
ConfigureFusionCachesettings now apply to SDK cache operations.DefaultEntryOptionsand override only SDK-specific settings.DeliveryClient.CacheManagerexposes the cache manager for standalone clients.Internal cleanup
CacheResult<T>.IsStalefor per-request fail-safe state.MemoryCacheManagerandHybridCacheManagerintoFusionCacheManager.Public API changes
Added:
DeliveryClient.CacheManagerCacheResult<T>.IsStaleDeliveryCacheDependencies.ForItemDeliveryCacheDependencies.ForTypeDeliveryCacheDependencies.ForTaxonomyDeliveryCacheDependencies.ForAssetNo public APIs were removed.
Consumer-visible behavior
404or other non-retryable response after invalidation no longer serves stale content.5xxor unavailable origin can still serve stale content when fail-safe is enabled.ConfigureFusionCachesettings such asDefaultEntryOptionsnow affect SDK operations.Verification
The four Redis-gated integration tests ran in CI against the pushed changes and pass, which matters here because this PR changes Redis key handling and purge behavior.
Documentation was also updated to reflect the new fail-safe behavior, invalidation rules, cache configuration, and multi-client behavior.